#pragma once

#include "View.h"
#include "MAISObj.h"
#include "DataExchange.h"

#include <QMainWindow>
#include <QComboBox>
#include <QStatusBar>
#include <QLabel>
#include <QActionGroup>
#include <QToolBar>
#include <QColorDialog>

#include "Geom_Plane.hxx"
#include "GeomAPI_ProjectPointOnSurf.hxx"
#include "RWObj_TriangulationReader.hxx"

class MainWindow: public QMainWindow
{
	Q_OBJECT
public:
	MainWindow(QWidget* parent = nullptr);
	~MainWindow();
	void initMenuToolbar();
	void initOCCTView();
	void setViewer(const Handle(V3d_Viewer)& theViewer) {
		myViewer = theViewer;
	}
	void initSignals();
	void setPerspective(bool check);
	void test();
	void setColor();
	void setSelectMode();
	void setWorkArea(int index);
	void processSelectChanged();

	void runAisCustom();

	void runModelData();

	void runBRepBuilderAPI();
	void runBRepPrimAPI();
	void runBRepOffsetAPI();
	void runModification();
	void runBoolean();
	void runHLR();

	void runDataExchange();

	void runAis();
	void runStdAis();
	void runGraphic3d();

	void runMShape();

protected:
	virtual bool eventFilter(QObject* watched , QEvent* event) override;

private:
	Handle(V3d_Viewer) Viewer(const V3d_TypeOfOrientation theViewProj);

	void updateStatusBar(const std::vector<double>& aNewPos);

	double _devPx;
	Handle(V3d_Viewer) myViewer;
	Handle(AIS_InteractiveContext) myContext;
	std::vector<double> myClickPos;
	std::vector<Handle(AIS_InteractiveObject)> objs;

	View* view_occt;
	QStatusBar* stb;
	QLabel* lb_positionInfo;

	std::vector< QToolBar*> tbs;
	QToolBar* tb_view;
	QAction* act_hideAll;
	QAction* act_hide;
	QAction* act_fitAll;
	QAction* act_axo;
	QAction* act_top;
	QAction* act_buttom;
	QAction* act_left;
	QAction* act_right;
	QAction* act_front;
	QAction* act_back;
	QAction* act_shade;
	QAction* act_wireframe;
	QAction* act_perspective;
	QAction* act_axis;
	QAction* act_test;

	QToolBar* tb_style;
	QAction* act_color;
	QAction* act_material;
	QActionGroup* actgp_selectMode;
	QAction* act_selectVertex;
	QAction* act_selectEdge;
	QAction* act_selectFace;
	QLabel* lb_workArea;
	QComboBox* cbb_workArea;

	QToolBar* tb_aisCustom;
	QComboBox* cbb_aisCustom;
	QAction* act_aisCustom;

	QToolBar* tb_ModelData;
	QComboBox* cbb_ModelData;
	QAction* act_ModelData;

	QToolBar* tb_ModelAlgorithm;
	QComboBox* cbb_BRepBuilderAPI;
	QAction* act_BRepBuilderAPI;
	QComboBox* cbb_BRepPrimAPI;
	QAction* act_BRepPrimAPI;
	QComboBox* cbb_BRepOffsetAPI;
	QAction* act_BRepOffsetAPI;
	QComboBox* cbb_Modification;
	QAction* act_Modification;
	QComboBox* cbb_Boolean;
	QAction* act_Boolean;
	QComboBox* cbb_HLR;
	QAction* act_HLR;

	QToolBar* tb_DataExchange;
	QComboBox* cbb_DataExchange;
	QAction* act_DataExchange;

	QToolBar* tb_Visualization;
	QComboBox* cbb_ais;
	QAction* act_ais;
	QComboBox* cbb_stdAis;
	QAction* act_stdAis;
	QComboBox* cbb_Graphic3d;
	QAction* act_Graphic3d;

	QToolBar* tb_MShape;
	QComboBox* cbb_MShape;
	QAction* act_MShape;
};
